import React, { Component } from 'react';

class Dog extends Component {
    constructor () {
      super()
      this.state = {
        isRunning: true,
        isBarking: true
      }
    }
  
    bark () {
        if(this.state.isBarking){
            console.log('bark');
        }
        setTimeout(() => this.setState({ isBarking: false }), 20)
    }
  
    run () {
        if(this.state.isRunning){
            console.log('run');
        }
        setTimeout(() => this.setState({ isRunning: false }), 20)
    }
    
    handleClickOnDog () {
      this.bark()
      this.run()
    }
  
    render() {
      return (
        <div onClick={this.handleClickOnDog.bind(this)}>DOG</div>
      )
    }
  }

export default Dog;